<template>
  <div class="commonTableSty h100">
    <s-table
      :columns="columns"
      :data-source="tbData"
      :loading="loadingBaseInfo"
      :showPagination="false"
      rowKey="id"
      class="h100"
    >
      <template
        slot-scope="text"
        v-for="column in commonColumns"
        :slot="column.scopedSlots.customRender"
      >
        <table-ellipsis :text="text" :key="column.key"></table-ellipsis>
      </template>
      <template #updateState="text">
        <table-ellipsis :text="taskEcuUpdateDictCodeObj[text] || '-'"></table-ellipsis>
      </template>
      <template #updateDuration="text,record">
        <table-ellipsis :text="$commonFun.getTwoDateDiff(record.startTime,record.endTime)"></table-ellipsis>
      </template>
    </s-table>
  </div>
</template>
<script>
import { tableShowTbColumns } from './config/list'
import TableEllipsis from '@/components/Ellipsis/TableEllipsis'
import { STable } from '@/components'
export default {
  components: {
    TableEllipsis,
    STable
  },
  props: {
    loadingBaseInfo: {
      type: Boolean,
      default: false
    },
    ecuLists: {
      type: Array,
      default () {
        return []
      }
    }
  },
  computed: {
    commonColumns () {
      return tableShowTbColumns.filter(item => !item.special)
    },
    tbData () {
      return this.ecuLists.map(item => {
        return {
          partNumber: item.ecuModuleId,
          partName: item.ecuName,
          softwareDid: item.ecuDid,
          ecuDiaId: item.ecuDiaId,
          targetVersionName: item.targetVersion,
          sourceVersionName: item.sourceVersion,
          startTime: item.startTime,
          endTime: item.endTime,
          status: item.status,
          id: item.id
        }
      })
    },
    taskEcuUpdateDictCodeObj () {
      return this.$store.getters.getDictCodeObj('taskEcuUpdateDictCode')
    }
  },
  data () {
    return {
      columns: tableShowTbColumns
    }
  },
  methods: {

  }
}
</script>
<style lang="less" scoped></style>
